/*
 * @Author: hongbin
 * @Date: 2022-10-23 20:04:05
 * @LastEditors: hongbin
 * @LastEditTime: 2022-11-01 15:30:48
 * @Description:模型加载
 */
import THREE, { createCallbackArray } from "../index";
import { setActerPosition } from "../object";
import { loadLDMap } from "./LDMap";

// 有体积的即 需要碰撞检测的
const withVolume = createCallbackArray();
//整个场景的物体
const objects = new THREE.Group();
objects.name = "LoadModels";
/**
 * 需要逐帧执行的操作
 */
const ticksClip: Array<() => void> = [];
const ticks = () => {
    ticksClip.forEach((tick) => tick());
};

const params: [Object3D, Object3D[]] = [objects, withVolume];

/**
 * 主线程加载模型
 */
const loadModels = (floor: THREE.Object3D) => {
    // loadRucksack(params[0]);
    // loadComputer(...params, floorHeight);
    // withVolume.push(toneTablet);
    // objects.add(toneTablet);
};

/**
 * 初始化辽东物体
 */
const initObjects = (complete?: (scene?: THREE.Scene) => void) => {
    loadLDMap(...params, complete);
};

/**
 * TODO 地下物体 -- 人物万一掉帧到地下获知状态 将人物升起
 */
// export const underground = {
//     // mesh: new Sphere(new Vector3(0, -1781, 0), 460 * 4),
//     needCalculate: (acterYAxisHeight: number) => {
//         return acterYAxisHeight < 80;
//     },
// };

const setActerPositionOnDefaultStar = () => {
    setActerPosition(new THREE.Vector3(-900, 0, -2460));
    // setActerPosition(new THREE.Vector3(-0, 0, -0));
};

export const ldMap = {
    init: initObjects,
    withVolume,
    objects,
    webWorkerLoadModels: [""],
    setActerPositionOnDefaultStar,
};
